#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
insert into edu_dwd.dt_teach_class_studying_student_count partition (dt)
select
       id,
       school_id,
       subject_id,
       class_id,
       studying_student_count,
       studying_date,
       dt
from edu_ods.teach_class_studying_student_count;


insert into edu_dwd.dt_teach_course_table_upload_detail partition (dt)
select
       id,
       base_id,
       class_id,
       class_date,
       content,
       teacher_id,
       teacher_name,
       job_number,
       classroom_id,
       classroom_name,
       is_outline,
       class_mode,
       is_stage_exam,
       is_pay,
       tutor_teacher_id,
       tutor_teacher_name,
       tutor_job_number,
       is_subsidy,
       answer_teacher_id,
       answer_teacher_name,
       answer_job_number,
       remark,
       create_time,
       dt
from edu_ods.teach_course_table_upload_detail
where if(content = '',null,content) is not null;

insert into edu_dwd.dt_teach_tbh_class_time_table partition (dt)
select
       id,
       class_id,
       morning_template_id,
       morning_begin_time,
       morning_end_time,
       afternoon_template_id,
       afternoon_begin_time,
       afternoon_end_time,
       evening_template_id,
       evening_begin_time,
       evening_end_time,
       use_begin_date,
       use_end_date,
       create_time,
       create_person,
       remark,
       dt
from edu_ods.teach_tbh_class_time_table;

insert into table edu_dwd.ft_teach_tbh_student_signin_record partition (dt)
select
       id,
       normal_class_flag,
       time_table_id,
       class_id,
       student_id,
       signin_time,
       signin_date,
       inner_flag,
       signin_type,
       share_state,
       inner_ip,
       dt
from edu_ods.teach_tbh_student_signin_record;

truncate table edu_dwd.ft_teach_student_leave_apply;

insert into edu_dwd.ft_teach_student_leave_apply partition (dt)
select
       id,
       class_id,
       student_id,
       audit_state,
       audit_person,
       audit_time,
       audit_remark,
       leave_type,
       leave_reason,
       begin_time,
       begin_time_type,
       end_time,
       end_time_type,
       days,
       cancel_state,
       cancel_time,
       old_leave_id,
       leave_remark,
       valid_state,
       create_time,
       dt
from edu_ods.teach_student_leave_apply
where valid_state = 1 and cancel_state = 0 and audit_state = 1 and leave_type = 1;

"